package com.atstudy.headline.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 内容表现日统计表
 * @TableName content_performance_daily
 */
@TableName(value ="content_performance_daily")
@Data
public class ContentPerformanceDaily {
    /**
     * ID
     */
    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     * 统计日期
     */
    private Date statDate;

    /**
     * 内容ID(为NULL表示所有内容)
     */
    private Integer contentId;

    /**
     * 分类ID(为NULL表示所有分类)
     */
    private Integer categoryId;

    /**
     * 作者ID(为NULL表示所有作者)
     */
    private Integer authorId;

    /**
     * 阅读量
     */
    private Integer viewCount;

    /**
     * 独立访客数
     */
    private Integer uniqueViewers;

    /**
     * 点赞数
     */
    private Integer likeCount;

    /**
     * 评论数
     */
    private Integer commentCount;

    /**
     * 分享数
     */
    private Integer shareCount;

    /**
     * 收藏数
     */
    private Integer favoriteCount;

    /**
     * 平均阅读时长(秒)
     */
    private Integer avgDuration;

    /**
     * 内容完读率(%)
     */
    private BigDecimal completionRate;

    /**
     * 创建时间
     */
    private Date createTime;

    //新闻标题
    @TableField(exist = false)
    private String contentTitle;

    //标题分类
    @TableField(exist = false)
    private String categoryName;

    //用户名称
    @TableField(exist = false)
    private String authorName;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        ContentPerformanceDaily other = (ContentPerformanceDaily) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getStatDate() == null ? other.getStatDate() == null : this.getStatDate().equals(other.getStatDate()))
            && (this.getContentId() == null ? other.getContentId() == null : this.getContentId().equals(other.getContentId()))
            && (this.getCategoryId() == null ? other.getCategoryId() == null : this.getCategoryId().equals(other.getCategoryId()))
            && (this.getAuthorId() == null ? other.getAuthorId() == null : this.getAuthorId().equals(other.getAuthorId()))
            && (this.getViewCount() == null ? other.getViewCount() == null : this.getViewCount().equals(other.getViewCount()))
            && (this.getUniqueViewers() == null ? other.getUniqueViewers() == null : this.getUniqueViewers().equals(other.getUniqueViewers()))
            && (this.getLikeCount() == null ? other.getLikeCount() == null : this.getLikeCount().equals(other.getLikeCount()))
            && (this.getCommentCount() == null ? other.getCommentCount() == null : this.getCommentCount().equals(other.getCommentCount()))
            && (this.getShareCount() == null ? other.getShareCount() == null : this.getShareCount().equals(other.getShareCount()))
            && (this.getFavoriteCount() == null ? other.getFavoriteCount() == null : this.getFavoriteCount().equals(other.getFavoriteCount()))
            && (this.getAvgDuration() == null ? other.getAvgDuration() == null : this.getAvgDuration().equals(other.getAvgDuration()))
            && (this.getCompletionRate() == null ? other.getCompletionRate() == null : this.getCompletionRate().equals(other.getCompletionRate()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getStatDate() == null) ? 0 : getStatDate().hashCode());
        result = prime * result + ((getContentId() == null) ? 0 : getContentId().hashCode());
        result = prime * result + ((getCategoryId() == null) ? 0 : getCategoryId().hashCode());
        result = prime * result + ((getAuthorId() == null) ? 0 : getAuthorId().hashCode());
        result = prime * result + ((getViewCount() == null) ? 0 : getViewCount().hashCode());
        result = prime * result + ((getUniqueViewers() == null) ? 0 : getUniqueViewers().hashCode());
        result = prime * result + ((getLikeCount() == null) ? 0 : getLikeCount().hashCode());
        result = prime * result + ((getCommentCount() == null) ? 0 : getCommentCount().hashCode());
        result = prime * result + ((getShareCount() == null) ? 0 : getShareCount().hashCode());
        result = prime * result + ((getFavoriteCount() == null) ? 0 : getFavoriteCount().hashCode());
        result = prime * result + ((getAvgDuration() == null) ? 0 : getAvgDuration().hashCode());
        result = prime * result + ((getCompletionRate() == null) ? 0 : getCompletionRate().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", statDate=").append(statDate);
        sb.append(", contentId=").append(contentId);
        sb.append(", categoryId=").append(categoryId);
        sb.append(", authorId=").append(authorId);
        sb.append(", viewCount=").append(viewCount);
        sb.append(", uniqueViewers=").append(uniqueViewers);
        sb.append(", likeCount=").append(likeCount);
        sb.append(", commentCount=").append(commentCount);
        sb.append(", shareCount=").append(shareCount);
        sb.append(", favoriteCount=").append(favoriteCount);
        sb.append(", avgDuration=").append(avgDuration);
        sb.append(", completionRate=").append(completionRate);
        sb.append(", createTime=").append(createTime);
        sb.append("]");
        return sb.toString();
    }
}
